package com.bingo.delay;

import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

@Component
public class DelayProducer {

    @Autowired
    RocketMQTemplate rocketMQTemplate;

    public void send(String payload) {
        Message<String> message = MessageBuilder.withPayload(payload).build();
        //private String messageDelayLevel = "1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h";
        SendResult sendResult = rocketMQTemplate.syncSend("Base:springboot:delay", message, 30000, 3);
        System.out.println("sendResult=" +  sendResult);
    }
}
